//
//  DetailCell.m
//  LOL视频播放
//
//  Created by 花花蔡 on 2016/12/9.
//  Copyright © 2016年 com.HuaHuaCai. All rights reserved.
//

#import "DetailCell.h"
#import "Public.h"
#import "UIImageView+WebCache.h"
@interface DetailCell ()

@property(nonatomic,strong) UIImageView *videoImage;
@property(nonatomic,strong) UILabel *videoTitle;
@property(nonatomic,strong) UILabel *videoTime;
@property(nonatomic,strong) UILabel *videoCount;



@end

@implementation DetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

+(instancetype)loadCellWithTableView:(UITableView *)tableView {
    
    static NSString *cellID = @"cell----qq";
    DetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[DetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
   self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setModel:(VideoModel *)model {
    [_videoImage sd_setImageWithURL:[NSURL URLWithString:model.P] placeholderImage:[UIImage imageNamed:@"占位图"]];
    _videoTitle.text = model.T;
    _videoTime.text = [model.A stringByReplacingOccurrencesOfString:@"T" withString:@" "];
    _videoCount.text = [NSString stringWithFormat:@"%@次播放",model.V];
}

- (void)setupUI {
    
    _videoImage = [[UIImageView alloc] initWithFrame:CGRectMake(6 * KWidth_ScaleW, 6 * KWidth_ScaleW, 128 * KWidth_ScaleW, 98 * KWidth_ScaleW)];
    _videoImage.layer.cornerRadius = 7;
    _videoImage.layer.masksToBounds = YES;
    [self.contentView addSubview:_videoImage];
    
    _videoTitle = [[UILabel alloc] initWithFrame:CGRectMake(146 * KWidth_ScaleW, 0, screen_width - 146 * KWidth_ScaleW, 67 * KWidth_ScaleW)];
    _videoTitle.font = [UIFont systemFontOfSize:21 * KWidth_ScaleW];
    _videoTitle.numberOfLines = 0;
    [self.contentView addSubview:_videoTitle];
    
    _videoTime = [[UILabel alloc] initWithFrame:CGRectMake(146 * KWidth_ScaleW, 86 * KWidth_ScaleW, 140 * KWidth_ScaleW, 18 * KWidth_ScaleW)];
    _videoTime.font = [UIFont systemFontOfSize:15 * KWidth_ScaleW];
    [self.contentView addSubview:_videoTime];
    
    _videoCount = [[UILabel alloc] initWithFrame:CGRectMake(screen_width - 112 * KWidth_ScaleW, 86 * KWidth_ScaleW, 104 * KWidth_ScaleW, 18 * KWidth_ScaleW)];
    _videoCount.font = [UIFont systemFontOfSize:15 * KWidth_ScaleW];
    _videoCount.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_videoCount];
    
    _videoImage.backgroundColor = [UIColor grayColor];
    _videoTitle.text = @"title______ title ";
    _videoTime.text = @"time-----time---time";
    _videoCount.text = @"视频:1110";
}

@end
